package com.yhq.spring.event.async;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author hqyin
 * @date 2023/3/13 3:04 下午
 */
@Component
@Slf4j
public class AsyncEventListener {
    @SneakyThrows
    @EventListener
    @Async
    public void asyncEvent(AsyncEvent asyncEvent) {
        log.info("receive async event：{},eventType:{}", asyncEvent.getMsgId(),asyncEvent.getType());
        Thread.sleep(10_000L);
        log.info("finish async event");
    }
}
